package com.tjetc.controller;

import com.tjetc.common.Resp;
import com.tjetc.entity.Appointment;
import com.tjetc.entity.User;
import com.tjetc.service.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin
@RestController
@RequestMapping("appointment")
public class AppointmentController {

    @Autowired
    private AppointmentService appointmentService;

    @RequestMapping("add")
    public Resp insert(@RequestBody Appointment appointment){
        System.out.println(appointment);
        return appointmentService.insertNewAppointment(appointment);
    }

    @RequestMapping("getAppointRoom")
    public Resp getAppointRoom(@RequestBody User user){
        System.out.println(user);
        return appointmentService.getAppointRoomByStuId(user.getId());
    }

    @RequestMapping("getMyAppoint")
    public Resp getMyAppoint(@RequestBody User user){
        System.out.println(user);
        return appointmentService.getMyAppointByUserId(user.getId());
    }

    @RequestMapping("getAllDisAgreeAppoint")
    public Resp getAllDisAgreeAppoint(){
        return appointmentService.getAllDisagreeAppoint();
    }

    @RequestMapping("disposeAppoint/{option}")
    public Resp disposeAppoint(@PathVariable("option") String option,@RequestBody Appointment appointment){
        System.out.println(option + " " + appointment);
        return appointmentService.disposeAppoint(option, appointment.getId());
    }

    @RequestMapping("teaGetRoom")
    public Resp teaGetRoom(@RequestBody User user){
        return appointmentService.teaGetRoom(user.getId());
    }

    @RequestMapping("getAll")
    public Resp getAll(){
        return appointmentService.getAllAppointment();
    }
}
